﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.IO;
using Mango.Communication;
using Blackbird.Utilities;

namespace Blackbird.Game.Session
{
    /// <summary>
    /// A class which constructs a habbo session for each user.
    /// </summary>
    class HabboSession
    {
        /// <summary>
        /// The ID of the user.
        /// </summary>
        public int id;

        /// <summary>
        /// The socket on which the user is connected.
        /// </summary>
        public Socket Socket;


        /// <summary>
        /// The manager server socket.
        /// </summary>
        public ServerSocket managerSocket;


        /// <summary>
        /// The weak referenced object.
        /// </summary>
        private WeakReference weakRef;

        /// <summary>
        /// The logging instance for this class.
        /// </summary>
        private Log log;


        /// <summary>
        /// Construct a new instance of a habbo session.
        /// </summary>
        /// <param name="id">The ID of the session.</param>
        /// <param name="socket">The socket of the session.</param>
        public HabboSession(int id, ServerSocket managerSocket)
        {
            
            this.id = id;
            this.managerSocket = managerSocket;
            this.log = new Log("HabboSession");
           // this.weakRef = new WeakReference(id);
           

        }

  

        public void Start()
        {
            string data = "@@";
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            byte[] pData = encoding.GetBytes(data);
           
        }

        /// <summary>
        /// Handle incoming data
        /// </summary>
        /// <param name="data">The byte array for the data</param>
        public void OnReceiveData(byte[] data)
        {
           using(BinaryReader reader = new BinaryReader(new MemoryStream(data)))
           if(data[0] == 60)
           {}
        }

        /// <summary>
        /// Handle the client's disconnection
        /// </summary>
        public void OnDisconnection()
        {
            if (this.Socket != null || this.Socket.Connected)
            {
               
                
            }
        }

    }
}
